import type { PageResult } from '#/type/base_beans';
import type { SysUserReq, SysUserResp } from '#/type/sys_user';

import { requestClient } from '#/api/request';

const API_PREFIX = '/sys/user';

export async function getUserByIdApi(id: string) {
  return requestClient.get<SysUserResp>(`${API_PREFIX}/get_by_id/${id}`);
}

export async function getUserListApi(params: SysUserReq) {
  return requestClient.get<Array<SysUserResp>>(`${API_PREFIX}/list`, {
    params,
  });
}

export async function getUserPageApi(params: SysUserReq) {
  return requestClient.get<PageResult<SysUserResp>>(`${API_PREFIX}/page`, {
    params,
  });
}

export async function createUserApi(data: SysUserReq) {
  return requestClient.post<Promise<void>>(`${API_PREFIX}/create`, data);
}

export async function editUserApi(data: SysUserReq) {
  return requestClient.put<Promise<void>>(`${API_PREFIX}/edit`, data);
}

export async function createEditUserApi(data: SysUserReq) {
  return requestClient.post<Promise<void>>(`${API_PREFIX}/create_edit`, data);
}

export async function deleteUserApi(ids: Array<string>) {
  return requestClient.delete<Promise<void>>(`${API_PREFIX}/delete`, {
    params: { ids },
  });
}

// export async function getAllUserWithDeptApi() {
//   return requestClient.get<PageResult<SysUserResp>>(
//     `${API_PREFIX}/get_all_user_with_dept`,
//   );
// }
